import { NgModule } from '@angular/core';
import { NavigationEnd, Router,RouterModule } from '@angular/router';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    {
                        path: 'dashboard',
                        loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule),
                        data: { permission: 'Pages.Tenant.Dashboard' }
                    },
                    {
                        path: 'welcome/:kind',
                        loadChildren: () => import('./blank/blank.module').then(m => m.BlankModule)
                    },
                    {
                        path: 'notifications',
                        loadChildren: () => import('./notifications/notifications.module').then(m => m.NotificationsModule)
                    },
                    {
                         path: 'content/:kind',
                         loadChildren: () => import('./content/content.module').then(m => m.ContentModule),
                    },
                    {
                        path: 'press/:kind',
                        loadChildren: () => import('./content2/content2.module').then(m => m.Content2Module),
                    },
                    {
                        path: 'menusInfo/:kind',
                        loadChildren: () => import('./menuInfo/menu-info.module').then(m => m.MenuInfoModule),
                    },
                    {
                        path: 'message/:kind',
                        loadChildren: () => import('./messages/message.module').then(m => m.MessageModule),
                    },
                    {
                        path:'workflowProduct/:kind', 
                        loadChildren: () => import('./workflow/list/workflow-product-list.module').then(m => m.WorkFlowProductListModule),
                    },
                    {
                        path:'workflowRecruitment/:kind', 
                        loadChildren: () => import('./workflow/list/workflow-recruitment-list.module').then(m => m.WorkFlowRecruitmentListModule),
                    },
                    { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
                    { path: '**', redirectTo: 'notifications' },
                ]
            }
        ])
    ],
    exports: [
        RouterModule
    ]
})
export class MainRoutingModule {

    constructor(
        private router: Router
    ) {
        router.events.subscribe((event) => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
